package com.jdrx.sw.sewage.api.web;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jdrx.platform.commons.rest.beans.vo.ResponseVO;
import com.jdrx.platform.commons.rest.factory.ResponseFactory2;
import com.jdrx.sw.sewage.beans.dto.base.PageDTO;
import com.jdrx.sw.sewage.common.constant.Constant;
import com.jdrx.sw.sewage.service.CameraServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/api/camera")
@Api(value = "摄像头模块")
public class CameraApi {

    public static final Logger logger = LoggerFactory.getLogger(CameraApi.class);
    @Autowired
    private CameraServiceImpl cameraServiceImpl;

    @ApiOperation(value = "获取摄像头列表")
    @RequestMapping(value = "getCameraListByPage", method = RequestMethod.POST)
    public ResponseVO<JSONObject> getCameraListByPage(@RequestHeader(Constant.TENANT_ID) String tenantId,
                                                      @RequestBody PageDTO pageDTO) throws Exception {
        return ResponseFactory2.ok(cameraServiceImpl.getCameraListByPage(pageDTO, tenantId));
    }

    @ApiOperation(value = "获取拉流地址")
    @RequestMapping(value = "getStreamUrl", method = RequestMethod.GET)
    public ResponseVO<JSONArray> getStreamUrl(@RequestHeader(Constant.TENANT_ID) String tenantId,
                                              @RequestParam("deviceSerial") String deviceSerial,
                                              @RequestParam("channelNo") Integer channelNo) throws Exception {
        return ResponseFactory2.ok(cameraServiceImpl.getStreamUrl(deviceSerial, channelNo, tenantId));
    }
}
